package com.example.kk.netty.netty;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.example.kk.netty.MainActivity;
import com.example.kk.netty.R;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import static android.R.attr.action;

public class HelloClientHandler extends SimpleChannelInboundHandler<String> {

	private  Handler handler;

	public HelloClientHandler(Handler view) {
		this.handler = view;
	}
	@Override
	protected void channelRead0(ChannelHandlerContext ctx, final String msg) throws Exception {
				Message message = new Message();
				message.what=11;
				message.obj=msg;
				handler.sendMessage(message);
		System.out.println("Server say : " + msg);
	}

	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("Client active ");
		super.channelActive(ctx);
	}

	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("Client close ");
		super.channelInactive(ctx);
	}




}